﻿using System;
using System.Collections.Generic;
using System.Data;
using cashbook_psql_cs.DAL;
using Npgsql;

namespace cashbook_psql_cs.BLL
{
    internal class RelationBillBLL
    {
        private readonly RelationBillDAL relationBillDAL = new RelationBillDAL();
        public DataTable FillDatasByRelationBill() {
           return relationBillDAL.GetRelationBill();
        }

        public bool AddRelationBill(RelationBill rb)
        {
             relationBillDAL.SaveRelationBill(rb);
            return true;
        }

        internal void ModifyRelationBill(RelationBill rb)
        {
            relationBillDAL.UpdateRelationBill(rb);
        }

        internal void RemoveRelationBill(RelationBill rb)
        {
            relationBillDAL.DeleteRelationBill(rb);
        }

        internal NpgsqlDataReader GetIncomeByMonth(string sql)
        {
            return relationBillDAL.FindIncomeByMonth(sql);

        }

        internal NpgsqlDataReader GetExpenseByMonth(string sql)
        {
            return relationBillDAL.FindExpenseByMonth(sql);
        }

        public List<RelationBill> GetDetailsByMonth(int year, int month, string type)
        {
            return relationBillDAL.FindDetailsByMonth(year,month,type); 
        }

        internal NpgsqlDataReader GetMonthlyData(string sqlTemplate, int year, string type)
        {
            return relationBillDAL.FindMonthlyData(sqlTemplate, year, type) ;
        }

        internal void CopyExcelDataToDb(string filePath)
        {
            relationBillDAL.ReadExcelDataToDb(filePath);
        }
    }
}
